package com.test.demo.listenter.listenterThree;

import com.test.demo.entity.UserBean;
import com.test.demo.event.UserRegisterEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;
/**
 * 监听事件的实现类
 */
@Component
public class RegisterListener implements ApplicationListener<UserRegisterEvent> {//实现ApplicationListener接口，并指定监听的事件类型
    /**
     * 实现监听
     * @param userRegisterEvent
     */
    @Override
    public void onApplicationEvent(UserRegisterEvent userRegisterEvent) {
        //获取注册用户对象
        UserBean user = userRegisterEvent.getUser();

        //../省略逻辑

        //输出注册用户信息
        System.out.println("ApplicationListener监听方式：注册信息，用户名："+user.getName()+"，密码："+user.getPassword());
    }
}